#!/usr/bin/perl -w

 # safediv.pl
 # Safe division which detects division-by-zero

 print "== Safe Division ==\n";
 print "Please enter the dividend > ";
 chomp($x = <STDIN>);
 print "Please enter the divisor > ";
 chomp($y = <STDIN>);

 $quotient = ($y || undef) && $x/$y;
 if (!defined $quotient) {
 print "Division by zero!\n";
 } else {
 print "$x / $y = $quotient\n";
 }